package br.com.fpf.pontoapp.ws.impl;

import java.util.ArrayList;
import java.util.List;

import br.com.fpf.pontoapp.ws.IInfoPoint;

/**
 * The Class InfoPonto.
 * 
 * @author irlan.gomes
 */
public class InfoPoint implements IInfoPoint {

	/** The user name. */
	private String userName;

	/** The work day. */
	private String workDay;

	/** The beats point. */
	private List<String> beatsPoint = new ArrayList<String>();

	/**
	 * Instantiates a new info ponto.
	 * 
	 * @param login
	 *            the login
	 * @param password
	 *            the password
	 */
	public InfoPoint(String login, String password) {
		String html = getHtml(login, password);
		parse(html);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see br.com.fpf.pontoapp.ws.INewConnection#getUserName()
	 */
	public String getUserName() {
		return userName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see br.com.fpf.pontoapp.ws.INewConnection#getWorkDay()
	 */
	public String getWorkDay() {
		return workDay;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see br.com.fpf.pontoapp.ws.INewConnection#getBeatsPoint()
	 */
	public List<String> getBeatsPoint() {
		return beatsPoint;
	}

	/**
	 * Gets the html.
	 * 
	 * @param login
	 *            the login
	 * @param password
	 *            the password
	 * @return the html
	 */
	private String getHtml(String login, String password) {
		return new NewConnection(login, password).getHtml();
	}

	/**
	 * Parses the.
	 * 
	 * @param html
	 *            the html
	 */
	private void parse(String html) {
		ParsePonto parsePonto = new ParsePonto();
		userName = parsePonto.getUserName();
		workDay = parsePonto.getWorkDay();
		beatsPoint = parsePonto.getBeatsPoint();
	}

}
